home *** CD-ROM | disk | FTP | other *** search
-
- ******************************************************************************
- * *
- * HodgePodge: An example Apple IIGS Desktop application *
- * *
- * Written in 65816 Assembler by the Apple IIGS Tools Team *
- * Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS" *
- * *
- * Copyright (c) 1986-87 by Apple Computer, Inc. *
- * *
- * ---------------------------------------------------------------------- *
- * *
- * ASM65816 Code file "FONT.ASM" -- Choose font; display font window contents *
- * *
- ******************************************************************************
-
-
-
- ***************************************************************
- *
- * FontData
- *
- ****************************************************************
- FontDATA DATA
-
- FontWinPtr ds 4
-
- DesiredFont dc i4'$0800FFFE' ; System Font size 8
- MonoFlag dc i2'0' ; start out showing proportional
-
- CurFontInfo anop
- CFAscent ds 2
- CFDescent ds 2
- CFMaxWid ds 2
- CFLeading ds 2
-
-
- CurHeight ds 2
- LineCounter ds 2
-
- CurPos ds 4
-
-
- NumLines equ 13
-
- LineTable dc i'Line0,Line1,Line2,Line3,Line4'
- dc i'Line5,Line6,Line7,Line8,Line9'
- dc i'Line10,Line11,Line12,Line12,Line12'
-
-
- Line0 ds 30 ; max name len is 25 + 1 for length
- ; ; and 4 for size info
- Line1 str ''
- Line2 str 'The quick brown fox jumped over the lazy dog.'
- Line3 str 'She sells sea shells down by the sea shore.'
- Line4 str ''
-
- Line5 dc h'20'
- dc h'00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F'
- dc h'10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F'
- Line6 dc h'20'
- dc h'20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F'
- dc h'30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F'
- Line7 dc h'20'
- dc h'40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F'
- dc h'50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F'
- Line8 dc h'20'
- dc h'60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F'
- dc h'70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F'
- Line9 dc h'20'
- dc h'80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F'
- dc h'90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F'
- Line10 dc h'20'
- dc h'A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF'
- dc h'B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF'
- Line11 dc h'20'
- dc h'C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF'
- dc h'D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF'
- Line12 dc h'20'
- dc h'E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF'
- dc h'F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF'
- END
-
- ****************************************************************
- *
- * DoChooseFont
- *
- ****************************************************************
- DoChooseFont START
- using GlobalDATA
- using FontDATA
-
- PushLong #0
- _GetPort
-
- PushLong #TempPort
- _OpenPort
-
- PushLong #0 ; space for result
- PushLong DesiredFont
- PushWord #0
- _ChooseFont
-
- lda 1,s
- ora 3,s
- bne ItChanged
-
- pla ; ChooseFont returned a 0000, so the
- pla ; font hasn't changed
-
- PushLong #TempPort
- _ClosePort
-
- _SetPort
-
- sec ; bad return
- rts
-
-
-
- ItChanged anop
- pla
- sta DesiredFont
- pla
- sta DesiredFont+2
-
- pushword #0 ;space for result
- PushWord DesiredFont
- PushLong #R_Fname
- _GetFamInfo
- pla ;ignore result
-
- lda DesiredFont+3 ; get font size in a reg
- and #$00FF
- pha
- lda #^R_FName ; high word of pointer to name
- pha
- lda R_FName
- and #$00FF
- inc a
- adc #R_FName
- pha ; low word of pointer
- PushWord #4 ; output length
- PushWord #0 ; not signed
- _Int2Dec
-
- lda R_FName ; bump the length
- inc a
- inc a
- inc a
- inc a
- sta R_FName
-
- PushLong #TempPort
- _ClosePort
-
- _SetPort
-
- clc ;good return
- rts
-
- TempPort ds $AA ; size of graph port
-
- END
-
- ****************************************************************
- *
- * DispFontWindow
- *
- ****************************************************************
- DispFontWindow START
- using FontDATA
- using GlobalData
-
- **********
- *
- * get my own zero page
- *
- **********
- phb
- phk
- plb
-
- phd
- lda MyZP
- tcd
-
- **********
- *
- * get the correct window port (got here from within taskmaster)
- *
- **********
-
- pushlong #0
- _GetPort
- plx
- ply ;get result for pushing in a sec.
-
- PUSHLONG #0 ;space for result
- phy
- phx ; saved the port here
- _GetWRefCon
-
- pla
- sta Temphandle
- plx
- stx TempHandle+2
-
- jsr Deref ; de reference
- sta 0
- stx 2
-
- ldy #oFontID+2 ; get the font ID
- lda [0],y
- tax
- dey
- dey
- lda [0],y
-
- jsl ShowFont
-
- lda TempHandle
- ldx TempHandle+2
- jsr Unlock
-
- pld
- plb
-
- rtl
-
- END
-
-
- ****************************************************************
- *
- * ShowFont
- *
- * Common routine to actually draw the contents of the window.
- * This routine is called with the font to install in the
- * in the A & X registers.
- *
- ****************************************************************
- ShowFont START
- using GlobalData
- using FontData
-
- phx ; save copy on stack
- pha
-
- phx ; install the font
- pha
- PushWord #0
- _InstallFont
-
- PushLong #CurFontInfo ; Get its size info
- _GetFontInfo
-
- stz LineCounter ; zero the line counter
-
- clc ; calculate the line separation
- lda CFAscent
- adc CFDescent
- adc CFLeading
- sta CurHeight
-
- PushWord #0 ; start the pen position at 0,0
- PushWord #0
- _MoveTo
-
- plx ; get fontid off stack
-
- pushword #0 ; space for result
- phx ; family number was in x
- PushLong #Line0
- _GetFamInfo
- pla ; ignore result
-
- pla ; high word of font id
- xba ; size in high byte
- and #$00FF
- pha
- lda #^Line0 ; high word of pointer to name
- pha
- lda Line0
- and #$00FF
- inc a
- adc #Line0
- pha ; low word of pointer
- PushWord #4 ; output length
- PushWord #0 ; not signed
- _Int2Dec
-
- lda Line0 ; bump the length
- inc a
- inc a
- inc a
- inc a
- sta Line0
-
- PushWord #0 ; save prev set mono/pro flag
- _GetFontFlags
-
- ldy #oFlag ; keep the result on the stack while
- lda [0],y ; we set it to what we want (as
- lsr a ; defined by its window type set up
- and #$0001 ; when we opened this window)
- pha
- _SetFontFlags
-
- LineLoop anop
-
- PushLong #CurPos ; get the current position
- _GetPen
-
-
- PushWord #5 ; reset x position
- lda CurPos
- clc
- adc CurHeight
- pha ; and y position
- _MoveTo
-
- lda LineCounter ; draw current line
- asl a
- tax
- phk
- phk
- lda 1,s
- and #$00FF
- sta 1,s
-
- lda LineTable,x
- pha
- _DrawString
-
- inc LineCounter ; bump current line
- lda LineCounter
- cmp #NumLines
- bcc LineLoop
-
- _SetFontFlags ; restore from saved position
-
- rtl
- END
-
- ****************************************************************
- *
- * doSetMono
- *
- ****************************************************************
-
- doSetMono START
- using FontData
- using MenuData
-
- lda MonoFlag
- eor #$02
- sta MonoFlag
-
- beq ChangeToMono ;Change message to show effect in
- PushLong #PropStr ;NEXT selection of this menu item
- bra PushID
- ChangeToMono PushLong #MonoStr
- PushID PushWord #MonoID
- _SetMItem
- rts
-
- END
-